<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/30
 * Time: 15:07
 */
namespace app\admin\model;


use think\Db;

class RealModel extends BaseModel
{
    protected $table = "xst_user";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
    /**
     * 首页
     */
    public function index()
    {
        $res = $this->order('createtime desc')->paginate(10,false,['query'=>request()->param()]);
        return $res;
    }
    /**
     * 获取单条信息
    */
    public function getOneId($id)
    {
        return $this->where('id',$id)->find();
    }
    /**
     * 修改认证信息
    */
    public function edit()
    {
        $flg = request()->post('flg');
        $id = request()->post('id');
        $data = [
            'flg'=>$flg,
        ];
        $res = $this->where('id',$id)->update($data);
        return $res;
    }
    public function del()
    {
        $id = request()->post('id');
        Db::startTrans();
        $res = $this->where('id',$id)->delete();
        $ress = Db::name('xst_balance')->where('id',$id)->delete();
        if($res && $ress)
        {
            Db::commit();
            return true;
        }else{
            Db::rollback();
            return false;
        }
    }
    public function dell()
    {
        $id = request()->post('id');
        $res = $this->where('id','in',$id)->delete();
        $ress = Db::name('xst_balance')->where('id','in',$id)->delete();
        if($res && $ress)
        {
            Db::commit();
            return true;
        }else{
            Db::rollback();
            return false;
        }
    }
}